﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.Text;
using StandardDAC.Base;

namespace StandardDAC.OleDb {
    public class OleColumn : DBColumn, IComparable<OleColumn> {
        short parameterOrder;

        public short ParameterOrder {
            get { return parameterOrder; }
            set { parameterOrder = value; }
        }

        public OleColumn(string name, OleDbType dbType, short parameterOrder)
            : base(name, dbType) {
            this.parameterOrder = parameterOrder;
        }

        public OleColumn(string name, OleDbType dbType, object nullValue, short parameterOrder)
            : base(name, dbType, nullValue) {
            this.parameterOrder = parameterOrder;
        }

        public OleColumn(string name, OleDbType dbType, object nullValue, bool isPrimaryKey, short parameterOrder)
            : base(name, dbType, nullValue, isPrimaryKey) {
            this.parameterOrder = parameterOrder;
        }
        public OleColumn(string name, OleDbType dbType, object nullValue, bool isPrimaryKey, short parameterOrder, bool isIdentity)
            : base(name, dbType, nullValue, isPrimaryKey, isIdentity) {
            this.parameterOrder = parameterOrder;
        }


        #region IComparable<OleColumn> Members

        public int CompareTo(OleColumn other) {
            return this.parameterOrder.CompareTo(other.ParameterOrder);
        }

        #endregion
    }
    public class StringOleColumn : OleColumn {
        public StringOleColumn(string name, short parameterOrder) : base(name, OleDbType.VarChar, parameterOrder) { }
        public StringOleColumn(string name, object nullValue, short parameterOrder) : base(name, OleDbType.VarChar, nullValue, parameterOrder) { }
    }
    public class PKOleColumn : OleColumn {
        public PKOleColumn(string name, short parameterOrder) : base(name, OleDbType.Integer, null, true, parameterOrder) { }
        public PKOleColumn(string name, object nullValue, short parameterOrder) : base(name, OleDbType.Integer, nullValue, true, parameterOrder) { }
        public PKOleColumn(string name, OleDbType dbType, object nullValue, short parameterOrder) : base(name, dbType, nullValue, true, parameterOrder) { }

        public PKOleColumn(string name, short parameterOrder, bool isIdentity) : base(name, OleDbType.Integer, null, true, parameterOrder, isIdentity) { }
        public PKOleColumn(string name, object nullValue, short parameterOrder, bool isIdentity) : base(name, OleDbType.Integer, nullValue, true, parameterOrder, isIdentity) { }
        public PKOleColumn(string name, OleDbType dbType, object nullValue, short parameterOrder, bool isIdentity) : base(name, dbType, nullValue, true, parameterOrder, isIdentity) { }
    }
    public class IdentityNotPKOleColumn : OleColumn {
        public IdentityNotPKOleColumn(string name, short parameterOrder) : base(name, OleDbType.Integer, null, false, parameterOrder, true) { }
        public IdentityNotPKOleColumn(string name, object nullValue, short parameterOrder) : base(name, OleDbType.Integer, nullValue, false, parameterOrder, true) { }
        public IdentityNotPKOleColumn(string name, OleDbType dbType, object nullValue, short parameterOrder) : base(name, dbType, nullValue, false, parameterOrder, true) { }
    }
}
